#pragma once

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/fcntl.h>
#include <sys/un.h>  
#include <stddef.h>
#include <sys/socket.h>
#include <string>
#include <iostream>
#include <thread>

#include "message.h"

class ubus_server{

private:
	fd_set readfds;
	int serverfd;
	int maxfd;
	struct sockaddr_un server_un;
	char *filename;
	std::string buf_;
public:
	ubus_server(const char *filename);
	~ubus_server();
	void init_server(const char *filename);
	void start();
	void handleMessage(int eventfd, std::string &message);
};
